<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>scrypt-async Unit Tests</title>
    <link rel="stylesheet" href="lib/mocha.css" />
  </head>
  <body>
    <div id="mocha"></div>
    <script src="lib/mocha.js"></script>
    <script>
        mocha.setup('bdd');
        mocha.timeout(20000);
    </script>
    <script src="lib/unittests-bundle.js"></script>
    <script>
        mocha.setup('bdd');
        mocha.timeout(20000);

        var runner = mocha.run();
        var failedTests = [];
        runner.on('end', function(){
          window.mochaResults = runner.stats;
          window.mochaResults.reports = failedTests;
        });
        runner.on('fail', function(test, err) {
          var flattenTitles = function(test) {
            var titles = [];
            while (test.parent.title) {
              titles.push(test.parent.title);
              test = test.parent;
            }
            return titles.reverse();
          };
          failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test)});
        });
    </script>
  </body>
</html>
